import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Recieve2 {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10086);

        Socket accept = serverSocket.accept();
        InputStream inputStream = accept.getInputStream();
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        int b;
        while ((b = inputStreamReader.read()) != -1) {
            System.out.print((char) b);

        }//接收到数据，开始回写
        String s = "服务器的回写数据";
        byte[] bytes = s.getBytes();
        OutputStream outputStream = accept.getOutputStream();
        outputStream.write(bytes);
        accept.close();
        serverSocket.close();
    }


}
